cmake_minimum_required(VERSION 3.14)

project(connectivity-plugin-for-linux)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

find_package(QT NAMES Qt5 COMPONENTS Widgets Network LinguistTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Network LinguistTools REQUIRED)

ADD_DEFINITIONS(-DQT_NO_KEYWORDS) # CONFIG += no_keywords qt关键字冲突

set(SUBDIRECTORIES_MAIN
        common
        connectmanage
        discovery
        connectivitymanager
        )
foreach (SUBDIRECTORY_MAIN ${SUBDIRECTORIES_MAIN})
    add_subdirectory(${SUBDIRECTORY_MAIN})
endforeach ()

set(TEST_SRCS
    "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
    "${CMAKE_CURRENT_SOURCE_DIR}/connectivitymanager/connectivitymanager.cpp"
    )

set(CONNECT_PLUGIN_SRCS
    "${CMAKE_CURRENT_SOURCE_DIR}/connect_plugin.cpp"
    "${CMAKE_CURRENT_SOURCE_DIR}/connectivitymanager/connectivitymanager.cpp"
    )

include_directories(
    ${PROJECT_SOURCE_DIR}/connectivitymanager
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
find_package(PkgConfig REQUIRED)
find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED)

add_library(connect_plugin SHARED 
        ${CONNECT_PLUGIN_SRCS}
        )

add_executable(test ${TEST_SRCS})

target_link_libraries(connect_plugin PUBLIC
        common
        # connectivitymanager
        connectmanage
        discovery
        -Wl,-rpath,${CMAKE_CURRENT_LIST_DIR}/lib/libQt5Core.so.5 
        -Wl,-Bsymbolic
)

target_link_libraries(test PUBLIC
        connect_plugin
)

